<?php

/**
 * Part of the Fuel framework.
 *
 * @package    Fuel
 * @version    1.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2012 Fuel Development Team
 * @link       http://fuelphp.com
 */

/**
 * Uri Class
 *
 * @package Fuel
 * @category Core
 * @author Dan Horrigan
 * @link http://docs.fuelphp.com/classes/uri.html
 */
class Uri extends Fuel\Core\Uri
{

    public static function login ($redirect = '')
    {
        if (! empty($redirect)) {
            $redirect = '?redirect_uri=' . urlencode($redirect);
        }
        
        return self::create('suser/login/sgame' . $redirect);
    }

    public static function logout ($redirect = '')
    {
        if (! empty($redirect)) {
            $redirect = '?redirect_uri=' . urlencode($redirect);
        }
        return self::create('http://dev.id.sgame.vn/user/logout/' . $redirect);
    }

    public static function current ($hash = '')
    {
        return current_url($hash);
    }

    public static function profile ($uid = NULL)
    {
        return self::create('profile/' . $uid);
    }

    public static function post ($id)
    {
        if (empty($id)) {
            return 'javascript:void(0); return \'invalid post id\';';
        }
        return self::create('post/index/' . $id);
    }

    public static function post_ajax ()
    {
        return self::create('post/add');
    }

    public static function post_flashdata_ajax ()
    {
        return self::create('post/flashdata');
    }

    public static function post_delete ()
    {
        return self::create('post/delete');
    }

    public static function feed ()
    {
        return self::create('feed/index');
    }

    public static function timthumb ($image, $key = 'sgame')
    {
        return Uri::create('images/timthumb.php?d=' . md5($image . $key) . '&url=' . urlencode($image) . '&w=320');
    }

    public static function wall ($user_id)
    {
        $user_id = (int) $user_id;
        return self::create('wall/' . $user_id);
    }

    public static function feed_more_ajax ()
    {
        return self::create('feed/loadmore');
    }

    public static function wall_more_ajax ()
    {
        return self::create('wall/loadmore');
    }

    public static function comment_ajax ()
    {
        return self::create('scomment/comment/add');
    }

    public static function comment_more ()
    {
        return self::create('scomment/comment/more');
    }

    public static function like_ajax ()
    {
        return self::create('slike/like/likeadd');
    }

    public static function like_list ()
    {
        return self::create('slike/like/likelist');
    }

    public static function friend_ajax ()
    {
        return self::create('sfriend/friend/verifyfriend');
    }

    public static function friend_reject_ajax ()
    {
        return self::create('sfriend/friend/rejectrequestfriend');
    }

    public static function friendlist_suggest_ajax ($uid = null)
    {
        return self::create('sfriend/friendlist/getfriendjson?uid=' . $uid);
    }

    public static function remove_notify ()
    {
        return self::create('snotif/notify/remove');
    }

    public static function remove_notifyfriendrequest ()
    {
        return self::create('sfriend/friend/remove');
    }

    public static function more_comment_ajax ()
    {
        return self::create('scomment/comment/more');
    }

    public static function message ()
    {
        return self::create('message/index');
    }

    public static function message_post ()
    {
        return self::create('message/add');
    }

    public static function message_append ()
    {
        return self::create('message/append');
    }

    public static function message_delete ()
    {
        return self::create('message/delete');
    }

    public static function message_autosuggest ()
    {
        return self::create('message/autosuggest');
    }

    public static function message_thread ($id)
    {
        return self::create('message/thread/' . $id);
    }

    public static function sgamelogout_redirect ()
    {
        return self::create('http://dev.id.sgame.vn/user/logout/?redirect=' . self::base(false));
    }

    public static function calltinyEditor ()
    {
        return self::create('assets/js/tiny_mce/tiny_mce.js');
    }

    public static function calltinyEditorCss ()
    {
        return self::create('assets/js/tiny_mce/content.css');
    }

    public static function apps ()
    {
        return Uri::create('apps');
    }

    public static function app_detail ($namespace)
    {
        return Uri::create('apps/' . $namespace);
    }

    public static function app_rating ($app_id)
    {
        return Uri::create('apps/rating/' . $app_id);
    }

    public static function question ($sort = '')
    {
        if (! empty($sort))
            $sort = '/' . $sort;
        
        return Uri::create('questions' . $sort);
    }

    public static function question_comment ($_id = '')
    {
        $post_id = '';
        if (! empty($_id)) {
            $post_id = '?post_id=' . $_id;
        }
        
        return Uri::create('questions/ajax/comment' . $post_id);
    }

    public static function question_ask ($_id = '')
    {
        if (empty($_id)) {
            return Uri::create('questions/ask');
        } else {
            return Uri::create('questions/ask/' . $_id);
        }
    }

    public static function question_answer ($_id = '')
    {
        if (empty($_id)) {
            return Uri::create('questions/answer');
        } else {
            return Uri::create('questions/answer/' . $_id);
        }
    }

    public static function question_tags ()
    {
        return Uri::create('questions/tags');
    }

    public static function question_tag ($slug)
    {
        return Uri::create('questions/tagsearch/' . $slug);
    }

    public static function question_tagsearch ()
    {
        return Uri::create('questions/tagsearch');
    }

    public static function question_titlesearch ($sort = '')
    {
        if (! empty($sort))
            $sort = '/' . $sort;
        
        return Uri::create('questions/titlesearch' . $sort);
    }

    public static function question_detail ($_id, $slug, $_segment = false)
    {
        if (is_object($_id)) {
            $_id = $_id->__toString();
        }
        
        if ($_segment) {
            $_segment = '#' . $_id;
        }
        return Uri::create('questions/detail/' . $_id . '/' . $slug . $_segment);
    }

    public static function question_delete ($_id)
    {
        if (is_object($_id)) {
            $_id = $_id->__toString();
        }
        
        return Uri::create('questions/delete/' . $_id . '/?redirect_uri=' . urlencode(Uri::current($_id)));
    }

    public static function question_users ($sort = '')
    {
        if (! empty($sort))
            $sort = '/' . $sort;
        
        return Uri::create('questions/users' . $sort);
    }

    public static function search ()
    {
        return Uri::create('search');
    }

    public static function rcquest_ajax ()
    {
        return self::create('squest/quest/complete');
    }

    public static function rrquest_ajax ()
    {
        return self::create('squest/quest/register_ajax');
    }

    public static function wall_Like_Box ()
    {
        return self::create('wall/');
    }

    public static function feed_UnfollowThisUser ()
    {
        return self::create('feed/unfollowuser');
    }

    public static function ajax_notif ()
    {
        return self::create('snotif/notify/ajax_notifi');
    }

    public static function feed_UnfollowThisPost ()
    {
        return self::create('feed/unfollowpost');
    }

    public static function FollowThisUser ()
    {
        return self::create('suser/profile/followuser');
    }

}


